package com.cloud.controller;


import com.cloud.entity.User;
import com.cloud.feign.UserFeign;
import com.cloud.service.UserService;
import com.cloud.util.JsonResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * (User)表控制层
 *
 * @author makejava
 * @since 2020-11-26 13:42:57
 */
@RestController
@RequestMapping("user")
public class UserController implements UserFeign {

    @Resource
    private UserService UserService;

    @PostMapping("update")
    public JsonResult update(Long money,Long userId){
//        int i = 10/0;
        User user = UserService.getById(userId);
        user.setMoney(user.getMoney()-money);
        user.updateById();
        return JsonResult.okMsg("修改成功");
    }
}